package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Commodity;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.ICommodityService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("commodities")
public class CommodityController {

    @Autowired
    private ICommodityService commodityService;

    /**
     * 获取所有商品
     * @param queryObject
     * @return
     */
    @GetMapping
    @ResponseBody
    public PageInfo list(QueryObject queryObject){
        return commodityService.query(queryObject);
    }

    /**
     * 获取商品详情
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    @ResponseBody
    public Commodity getById(@PathVariable Long id){
        return commodityService.getById(id);
    }
}
